<template>
	<view class="box">
		<view class="record">
			<view class="top" @click="onIncome">
				<image :src="$util.prefix('game/tag_top.png')" mode="aspectFill"></image>
			</view>
			<view class="bottom" @click="onPlatform">
				<image :src="$util.prefix('game/tag_bottom.png')" mode="aspectFill"></image>
			</view>
		</view>

		<u-popup :show="platform_show" @close="platform_show = false" mode="center" bgColor="transparent">
			<view class="platform flex_c"
				:style="`background: url(${$util.prefix('game/platform_records_bg.png')}) 0 0 no-repeat;`">

				<view class="title">
					茶会记录
				</view>

				<view class="record-table">
					<view class="record-header flex_center">
						<view class="item w30">进场时间</view>
						<view class="item w50">进场动物</view>
						<view class="item w20">所需午餐</view>
					</view>
				</view>

				<view class="record-content">
					<scroll-view scroll-y="true" @scrolltolower="onReachPlatform">
						<view class="record-list flex_center" v-for="(item,index) in platform_list" :key="index">
							<view class="item w30">
								<text class="time">{{ item.time }}</text>
							</view>

							<view class="item w50">
								<view class="flex_c">
									<view class="image">
										<image :src="$util.prefix(`game/boss2.png`)" mode="widthFix"
											v-if="item.prize_boss_gid != 0"></image>
										<image :src="$util.prefix(`game/elephant2.png`)" mode="widthFix"
											v-else-if="item.prize_food == 1"></image>
										<image :src="$util.prefix(`game/raccoon2.png`)" mode="widthFix"
											v-else-if="item.prize_food == 2"></image>
										<image :src="$util.prefix(`game/monkey2.png`)" mode="widthFix"
											v-else-if="item.prize_food == 3"></image>
										<image :src="$util.prefix(`game/lion2.png`)" mode="widthFix"
											v-else-if="item.prize_food == 4"></image>
										<image :src="$util.prefix(`game/rabbit2.png`)" mode="widthFix"
											v-else-if="item.prize_food == 5"></image>
										<image :src="$util.prefix(`game/panda2.png`)" mode="widthFix"
											v-else-if="item.prize_food == 6"></image>
										<image :src="$util.prefix(`game/fox2.png`)" mode="widthFix"
											v-else-if="item.prize_food == 7"></image>
										<image :src="$util.prefix(`game/tiger2.png`)" mode="widthFix"
											v-else-if="item.prize_food == 8"></image>
									</view>
									<view class="text">{{
										item.prize_boss_gid != 0 ? 'BOSS'
										: item.prize_food == 1 ? '大象'
										: item.prize_food == 2 ? '浣熊'
										: item.prize_food == 3 ? '猴子'
										: item.prize_food == 4 ? '狮子'
										: item.prize_food == 5 ? '兔子'
										: item.prize_food == 6 ? '熊猫'
										: item.prize_food == 7 ? '狐狸'
										: item.prize_food == 8 ? '老虎'
										: ''
									}}</view>
								</view>
							</view>

							<view class="item w20">
								<view class="flex_c">
									<view class="goods-image">
										<image :src="$util.prefix(`game/gift_image${item.prize_food}.png`)"
											mode="aspectFill"></image>
									</view>
									<view class="text">{{ item.prize_gift_name }}</view>
								</view>
							</view>
						</view>
					</scroll-view>
				</view>

			</view>
		</u-popup>


		<u-popup :show="income_show" @close="income_show = false" mode="center" bgColor="transparent">
			<view class="income flex_c"
				:style="`background: url(${$util.prefix('game/platform_records_bg.png')}) 0 0 no-repeat;`">

				<view class="title">
					消费记录
				</view>

				<view class="income-header flex_r_between">
					<text>花费</text>
					<text>奖励</text>
				</view>

				<view class="empty flex_r_around" v-if="!income_list.length">
					<view class="flex_c">
						<image :src="$util.prefix('game/empty.png')" mode="aspectFill"></image>
						<text>暂无数据</text>
					</view>
				</view>

				<view class="content" v-if="income_list.length">
					<scroll-view scroll-y="true">
						<view class="list" v-for="(item,index) in income_list" :key="index">
							<view class="header flex_r_between">
								<view class="flex_center">
									<image :src="$util.prefix('game/buy_grass_icon.png')" mode="aspectFill"></image>
									<text>x{{ item.order_num }}</text>
								</view>
								<!-- //是否中奖 0=否，1=中奖，2=不展示 -->
								<i>{{ item.order_status == 0 ? '投喂失败' : item.order_status == 1 ? '投喂成功' : '' }}</i>
							</view>
							<view class="record-list flex_center">
								<view class="item w30">
									<text class="time">{{ item.time }}</text>
								</view>

								<view class="item w50">
									<view class="flex_c">
										<view class="image">
											<image :src="$util.prefix(`game/boss2.png`)" mode="widthFix"
												v-if="item.prize_boss_gid != 0"></image>
											<image :src="$util.prefix(`game/elephant2.png`)" mode="widthFix"
												v-else-if="item.order_food == 1"></image>
											<image :src="$util.prefix(`game/raccoon2.png`)" mode="widthFix"
												v-else-if="item.order_food == 2"></image>
											<image :src="$util.prefix(`game/monkey2.png`)" mode="widthFix"
												v-else-if="item.order_food == 3"></image>
											<image :src="$util.prefix(`game/lion2.png`)" mode="widthFix"
												v-else-if="item.order_food == 4"></image>
											<image :src="$util.prefix(`game/rabbit2.png`)" mode="widthFix"
												v-else-if="item.order_food == 5"></image>
											<image :src="$util.prefix(`game/panda2.png`)" mode="widthFix"
												v-else-if="item.order_food == 6"></image>
											<image :src="$util.prefix(`game/fox2.png`)" mode="widthFix"
												v-else-if="item.order_food == 7"></image>
											<image :src="$util.prefix(`game/tiger2.png`)" mode="widthFix"
												v-else-if="item.order_food == 8"></image>
										</view>
										<view class="text">{{
										item.prize_boss_gid != 0 ? 'boss'
										: item.order_food == 1 ? '大象'
										: item.order_food == 2 ? '浣熊'
										: item.order_food == 3 ? '猴子'
										: item.order_food == 4 ? '狮子'
										: item.order_food == 5 ? '兔子'
										: item.order_food == 6 ? '熊猫'
										: item.order_food == 7 ? '狐狸'
										: item.order_food == 8 ? '老虎'
										: ''
									}}</view>
									</view>
								</view>

								<view class="item w20">
									<view class="flex_c">
										<view class="goods-image">
											<image :src="$util.prefix(`game/gift_image${item.order_food}.png`)"
												mode="aspectFill"></image>
										</view>
										<view class="text">{{ item.order_gift_name }}</view>
									</view>
								</view>
							</view>
						</view>
					</scroll-view>
				</view>

			</view>
		</u-popup>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				platform_show: false,
				income_show: false,

				platform_page: 1,
				platform_total: 1,
				platform_list: [],

				income_page: 1,
				income_total: 1,
				income_list: [],
			}
		},
		methods: {
			onPlatform() {
				this.platform_list = [];
				this.platform_page = 1;
				this.platform_total = 1;
				this.getOpenPrizeLog();
				this.platform_show = true;
			},

			onIncome() {
				this.income_list = [];
				this.income_page = 1;
				this.income_total = 1;
				this.getMyPrizeLog();
				this.income_show = true;
			},

			// 茶会记录
			getOpenPrizeLog() {
				this.$get('/active.animalPrize/getOpenPrizeLog', {
					page: this.platform_page,
				}).then(res => {
					this.platform_total = res.data.total;
					this.platform_list.push(...res.data.data);
				});
			},

			onReachPlatform() {
				if (this.platform_total > this.platform_list.length) {
					this.platform_page++;
					this.getOpenPrizeLog();
				}
			},

			// 消费记录
			getMyPrizeLog() {
				this.$get('/active.animalPrize/getMyPrizeLog', {
					page: this.income_page,
				}).then(res => {
					this.income_total = res.data.total;
					this.income_list.push(...res.data.data);
				});
			},

			onReachIncome() {
				if (this.income_total > this.income_list.length) {
					this.income_page++;
					this.getMyPrizeLog();
				}
			},
		}
	}
</script>

<style lang="less" scoped>
	.record {
		width: 206rpx;
		height: 206rpx;
		position: absolute;
		bottom: 338rpx;
		right: 10rpx;
		z-index: 1;

		.top {
			width: 156rpx;
			height: 74rpx;
			position: absolute;
			top: 0;
			left: -4rpx;

			image {
				width: 156rpx;
				height: 74rpx;
			}
		}

		.bottom {
			width: 152rpx;
			height: 136rpx;
			position: absolute;
			bottom: 0;
			right: 0;

			image {
				width: 152rpx;
				height: 136rpx;
			}
		}
	}

	.platform {
		width: 100vw;
		height: 100vw;
		background-size: 100% !important;
		padding: 18rpx 82rpx 110rpx;
		position: relative;
		z-index: 99;

		.title {
			font-size: 32rpx;
			color: #FFEABB;
			line-height: 38rpx;
		}
	}

	.record-header {
		width: 588rpx;
		padding: 32rpx 0 14rpx;

		.w20 {
			width: 20%;
		}

		.w30 {
			width: 30%;
		}

		.w50 {
			width: 50%;
		}

		.item {
			font-size: 26rpx;
			color: #E67F10;
			line-height: 36rpx;
		}
	}

	.record-content {
		width: 588rpx;
		flex: 1;
		overflow: hidden;

		scroll-view {
			height: 100%;
		}

		.record-list {
			height: 144rpx;
			background: #FEE5A6;
			border-radius: 24rpx;
			margin-bottom: 8rpx;

			.w20 {
				width: 20%;
			}

			.w30 {
				width: 30%;
			}

			.w50 {
				width: 50%;
			}

			.item {
				display: flex;
				flex-direction: column;
				align-items: flex-start;

				.time {
					font-size: 24rpx;
					color: #BE7C4A;
					line-height: 28rpx;
					padding-left: 22rpx;
				}

				.image {
					width: 88rpx;
					height: 81rpx;
					overflow: hidden;

					image {
						width: 88rpx;
					}
				}

				.goods-image {
					width: 56rpx;
					height: 56rpx;

					image {
						width: 56rpx;
						height: 56rpx;
					}
				}

				.text {
					font-size: 24rpx;
					color: #8D440E;
					line-height: 34rpx;
				}
			}
		}
	}

	.income {
		width: 100vw;
		height: 100vw;
		background-size: 100% !important;
		padding: 18rpx 82rpx 110rpx;
		position: relative;
		z-index: 99;

		.title {
			font-size: 32rpx;
			color: #FFEABB;
			line-height: 38rpx;
		}

		.income-header {
			width: 588rpx;
			padding: 32rpx 22rpx 14rpx;

			text {
				font-size: 26rpx;
				color: #E67F10;
				line-height: 36rpx;
			}
		}

		.content {
			flex: 1;
			width: 588rpx;
			overflow: hidden;

			scroll-view {
				height: 100%;
			}

			.list {
				margin-bottom: 8rpx;
			}

			.record-list {
				height: 144rpx;
				background: #FEE5A6;
				border-radius: 0rpx 0rpx 24rpx 24rpx;

				.w20 {
					width: 20%;
				}

				.w30 {
					width: 30%;
				}

				.w50 {
					width: 50%;
				}

				.item {
					display: flex;
					flex-direction: column;
					align-items: flex-start;

					.time {
						font-size: 24rpx;
						color: #BE7C4A;
						line-height: 28rpx;
						padding-left: 22rpx;
					}

					.image {
						width: 88rpx;
						height: 81rpx;
						overflow: hidden;

						image {
							width: 88rpx;
						}
					}

					.goods-image {
						width: 56rpx;
						height: 56rpx;

						image {
							width: 56rpx;
							height: 56rpx;
						}
					}

					.text {
						font-size: 24rpx;
						color: #8D440E;
						line-height: 34rpx;
					}
				}
			}

			.header {
				height: 56rpx;
				background: #DFA46E;
				border-radius: 24rpx 24rpx 0rpx 0rpx;
				padding: 0 24rpx;

				text {
					font-weight: 500;
					font-size: 24rpx;
					color: #FFFFFF;
					line-height: 28rpx;
				}

				image {
					width: 44rpx;
					height: 44rpx;
				}

				i {
					font-size: 24rpx;
					color: #9D0000;
					line-height: 28rpx;
					font-style: normal;
				}
			}

		}

		.empty {
			flex: 1;
			width: 588rpx;
			padding-bottom: 80rpx;

			image {
				width: 288rpx;
				height: 240rpx;
			}

			text {
				font-family: 'gongfu';
				font-size: 28rpx;
				color: #507336;
				line-height: 30rpx;
			}
		}

	}
</style>